home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
os2
/
pccts.zip
/
PARSER.DLG
< prev
next >
Wrap
Text File
|
1992-12-08
|
3KB
|
240 lines
<<
/* parser.dlg -- DLG Description of scanner
*
* Generated from: dlg_p.g
*
* Terence Parr, Hank Dietz and Will Cohen: 1989-1992
* Purdue University Electrical Engineering
* ANTLR Version 1.06
*/
#include <stdio.h>
#include <ctype.h>
#include "dlg.h"
#ifdef MEMCHK
#include "trax.h"
#else
extern char *malloc();
extern char *calloc();
#endif
#include "antlr.h"
#include "tokens.h"
#include "dlgdef.h"
LOOKAHEAD
void zzerraction()
{
(*zzerr)("invalid token");
zzadvance();
zzskip();
}
>>
<<
#include "dlgdef.h"
int func_action; /* should actions be turned into functions?*/
int lex_mode_counter = 0; /* keeps track of the number of %%names */
>>
%%START
@
<<
NLA = 1;
>>
[\r\t\ ]+
<<
NLA = 2;
zzskip();
>>
[\n]
<<
NLA = 3;
zzline++; zzskip();
>>
\@
<<
NLA = L_EOF;
>>
\%\%
<<
NLA = PER_PER;
>>
\%\%[a-zA-Z_][a-zA-Z0-9_]*
<<
NLA = NAME_PER_PER;
p_mode_def(&zzlextext[2],lex_mode_counter++);
>>
\<\<
<<
NLA = ACTION;
if (func_action)
fprintf(OUT,"static void\nact%d()\n{ ", ++action_no);
zzmode(ACT); zzskip();
>>
\>\>
<<
NLA = GREAT_GREAT;
>>
\{
<<
NLA = L_BRACE;
>>
\}
<<
NLA = R_BRACE;
>>
\(
<<
NLA = L_PAR;
>>
\)
<<
NLA = R_PAR;
>>
\[
<<
NLA = L_BRACK;
>>
\]
<<
NLA = R_BRACK;
>>
\*
<<
NLA = ZERO_MORE;
>>
\+
<<
NLA = ONE_MORE;
>>
\|
<<
NLA = OR;
>>
\-
<<
NLA = RANGE;
>>
\~
<<
NLA = NOT;
>>
\\0[0-7]*
<<
NLA = OCTAL_VALUE;
{int t; sscanf(&zzlextext[1],"%o",&t); zzlextext[0] = t;}
>>
\\0[Xx][0-9a-fA-F]+
<<
NLA = HEX_VALUE;
{int t; sscanf(&zzlextext[1],"%x",&t); zzlextext[0] = t;}
>>
\\[1-9][0-9]*
<<
NLA = DEC_VALUE;
{int t; sscanf(&zzlextext[1],"%d",&t); zzlextext[0] = t;}
>>
\\t
<<
NLA = TAB;
zzlextext[0] = '\t';
>>
\\n
<<
NLA = NL;
zzlextext[0] = '\n';
>>
\\r
<<
NLA = CR;
zzlextext[0] = '\r';
>>
\\b
<<
NLA = BS;
zzlextext[0] = '\b';
>>
\\~[tnrb]
<<
NLA = LIT;
zzlextext[0] = zzlextext[1];
>>
~[\\]
<<
NLA = REGCHAR;
>>
%%ACT
@
<<
NLA = 1;
error("unterminated action", zzline); zzmode(START);
>>
\>\>
<<
NLA = ACTION;
if (func_action) fprintf(OUT,"}\n\n");
zzmode(START);
>>
\>
<<
NLA = 29;
putc(zzlextext[0], OUT); zzskip();
>>
\\\>
<<
NLA = 30;
putc('>', OUT); zzskip();
>>
\\
<<
NLA = 31;
putc('\\', OUT); zzskip();
>>
\n
<<
NLA = 32;
putc(zzlextext[0], OUT); ++zzline; zzskip();
>>
~[\>\\@\n]+
<<
NLA = 33;
fprintf(OUT, "%s", &(zzlextext[0])); zzskip();
>>
%%